package formbeans;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class BinaryQuestionForm extends FormBean {

	private String binChoice;
	
	public String getBinChoice() {
		return binChoice;
	}

	public void setBinChoice(String binChoice) {
		this.binChoice = binChoice;
	}
	
	public List<String> checkBinaryQuestionFormErrors(){
		List<String> errors = new ArrayList<String>();
		
		if (isEmpty(binChoice)) {
			errors.add("Please choose an answer");
			return errors;
		}
		if (!(binChoice.equals("0") || binChoice.equals("1"))) {
			errors.add("Invalid choice");
		}
		
		return errors;
	}
	
	private boolean isEmpty(String str) {
		return (str == null || str.length() == 0);
	}
}